//
//  HotPlace_DetilCollectionViewCell.m
//  Travel_M_Travel
//
//  Created by APPLE10 on 15-4-6.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "HotPlace_DetilCollectionViewCell.h"

@implementation HotPlace_DetilCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.myImageView = [[UIImageView alloc]init];
        _myImageView.contentMode = UIViewContentModeScaleAspectFill;
        _myImageView.layer.cornerRadius = 10;
        _myImageView.clipsToBounds = YES;
        
        
        self.nameLable = [[UILabel alloc]init];
        _nameLable.font = [UIFont fontWithName:@"Georgia" size:17];
        
        self.recommended_reasonLable = [[UILabel alloc]init];
        _recommended_reasonLable.font = [UIFont fontWithName:@"Georgia" size:12];
        _recommended_reasonLable.numberOfLines = 2;
        
        self.ratingLable = [[UILabel alloc]init];
        
        [self.contentView addSubview:_ratingLable];
        [self.contentView addSubview:_myImageView];
        [self.contentView addSubview:_nameLable];
        [self.contentView addSubview: _recommended_reasonLable];
        
        [_nameLable release];
        [_myImageView release];
        [_ratingLable release];
        [_recommended_reasonLable release];
    }
    
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    CGFloat width = self.contentView.frame.size.width;
    CGFloat height = self.contentView.frame.size.height;
    
    _myImageView.frame = CGRectMake(5, 10, width/ 3, height*8/10);
    _nameLable.frame = CGRectMake(width / 3 + 5, 10, width * 2 / 3, height / 5);
    _ratingLable.frame = CGRectMake(width / 3 +5, height / 5, width * 2 /3 , height / 5);
    _recommended_reasonLable.frame = CGRectMake(width / 3 + 5, height *2/ 5, width * 2/ 3 , height* 2/ 5);
    
}

- (void)setHotData:(HotPlaceDataSource *)hotData
{
    if (_hotData != hotData) {
        [_hotData release];
        _hotData = [hotData retain];
    }
    NSString *str = [hotData.cover_s stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    [self.myImageView setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"jiazai.png"]];
    self.nameLable.text = hotData.name;
    self.recommended_reasonLable.text = hotData.recommended_reason;
    
    NSString *strRating = [NSString stringWithFormat:@"%@",hotData.rating];
    
    self.ratingLable.text = strRating;
    
}
@end
